from ctypes.wintypes import RECT
from ctypes import byref, windll
import appModuleHandler, mouseHandler, tones, ui, winUser
# 应用模块
class AppModule(appModuleHandler.AppModule):
    def event_gainFocus(self, obj, nextHandler):
        if 'Chrome_RenderWidgetHostHWND' == obj.windowClassName:
            # YY 频道内嵌网页优化
            name = obj.name
            if name:
                ui.message (name)
            nextHandler()
            return
        # 频道窗口自动设定内嵌网页焦点
        rect = RECT ()
        if not windll.user32.GetWindowRect (obj.windowHandle, byref(rect)):return
        x, y = rect.left + 10, rect.top + 10
        winUser.setCursorPos(x, y)
        mouseHandler.executeMouseMoveEvent(x, y)
        mouseHandler.doPrimaryClick